package main

import (
	"bytes"
	"fmt"
)

func main() {
	b1 := bytes.NewBufferString("abc")
	fmt.Printf("Lan: %d, Cap: %d.\n", b1.Len(), b1.Cap())
	s1 := b1.Bytes()
	fmt.Printf("%[1]v, %[1]s\n", s1)
	b1.WriteString("123")
	fmt.Printf("Lan: %d, Cap: %d.\n", b1.Len(), b1.Cap())
	fmt.Printf("%[1]v, %[1]s\n", s1)
	// 这里只要扩充一下切片，就读到后续内容了
	s1 = s1[:cap(s1)]
	fmt.Printf("%[1]v, %[1]s\n", s1)
	// 只是读到还不算，还能改
	s1[len(s1)-3] = 'X'
	fmt.Printf("%[1]v, %[1]s\n", s1)
}